package com.stormrage.edu.dao.learn.impl;

import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Repository;

import com.stormrage.edu.dao.learn.LeaBunchApplyDao;
import com.stormrage.entity.learn.LeaBunchApply;
import com.stormragetech.core.dao.MysBaseDao;
import com.stormragetech.core.exception.StormrageTechException;

/**
 * @Title: LeaBunchApplyDaoImpl.java
 * @Package com.stormrage.edu.dao.learn.impl
 * @Description: 报名 Dao
 * @author www.stormragetech.com
 * @date 2016年4月14日
 * @version V1.0
 */
@Repository
public class LeaBunchApplyDaoImpl extends MysBaseDao implements LeaBunchApplyDao {

	private static final Logger logger = LoggerFactory.getLogger(LeaBunchApplyDaoImpl.class);

	@Override
	public Integer create(LeaBunchApply arg0) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 LeaBunchApplyDao 】-【 Create 】- 开始运行 ");

		final String query = "INSERT INTO lea_bunch_apply (bunch_id, ent_id, excel, apply_date, locked) VALUES"
				+ " (:bunchId, :entId, :excel, :applyDate, :locked)";
		logger.debug(" 数据库执行语句为 " + query);

		Integer index = create(query, arg0);

		logger.debug(" 【 Dao 】-【 LeaBunchApplyDao 】-【 Create 】- 完成运行 ");
		return index;

	}

	@Override
	public LeaBunchApply queryByEntBunchLock(final Map<String, Object> map) throws StormrageTechException {

		logger.debug(" 【 Dao 】-【 LeaBunchApplyDao 】-【 queryByEntBunch 】- 开始运行 ");

		final String query = "SELECT * FROM lea_bunch_apply WHERE bunch_id = :bunchId AND ent_id = :entId"
				+ " AND locked = :locked";
		logger.debug(" 数据库执行语句为 " + query);

		LeaBunchApply entity = queryObject(query, LeaBunchApply.class, map);

		logger.debug(" 【 Dao 】-【 LeaBunchApplyDao 】-【 queryByEntBunch 】- 完成运行 ");
		return entity;

	}

}
